import request from '@/utils/request'

const baseURL = '/api/course'

export function getCourseList({
                                   page, pageSize, params = {}, data
                                 }) {
  return request({
    url: baseURL + '/list',
    method: 'post',
    params: {
      page, pageSize,
      ...params
    }, data
  })
}

export function getElectiveCourseList({
                                   page, pageSize, params = {}, data
                                 }) {
  return request({
    url: baseURL + '/electiveCourseList',
    method: 'post',
    params: {
      page, pageSize,
      ...params
    }, data
  })
}

export function getUnArrangedCourseList(year, semester) {
  return request({
    url: baseURL + '/unArrangedCourseList',
    method: 'get',
    params: {
      year, semester
    }
  })
}

export function getOneCourse(id) {
  return request({
    url: baseURL + `/${id}`,
    method: 'get'
  })
}

export function addCourse(data) {
  return request({
    url: baseURL,
    method: 'post',
    data
  })
}

export function updateCourse(id, data) {
  return request({
    url: baseURL + `/${id}`,
    method: 'put',
    data
  })
}

export function deleteOneCourse(id) {
  return request({
    url: baseURL + `/${id}`,
    method: 'delete'
  })
}
